package com.david.func_test.snaphelper;

import android.os.Bundle;
import android.view.Gravity;


import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.david.func_test.R;

import java.util.ArrayList;

public class SnapHelperActivity extends AppCompatActivity {
    RecyclerView mRecyclerView;
    ArrayList<String> mData;
    LinearLayoutManager mLayoutManager;
    GallerySnapHelper mGallerySnapHelper;
//    DiscoverActiveSnapHelper mGallerySnapHelper;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_snap_helper);
        mRecyclerView = (RecyclerView) findViewById(R.id.recyclerview);
        mLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
        mRecyclerView.setLayoutManager(mLayoutManager);
//        mRecyclerView.setLayoutManager(new GridLayoutManager(this, 2,LinearLayoutManager.HORIZONTAL, false));
        initData();
        mRecyclerView.setAdapter(new SnapHelperAdapter(this, mData));
        mGallerySnapHelper = new GallerySnapHelper();
//        mGallerySnapHelper = new DiscoverActiveSnapHelper();
//        mGallerySnapHelper.attachToRecyclerView(mRecyclerView);


//        new TopSnapHelper().attachToRecyclerView(mRecyclerView);
        GravitySnapHelper snapHelper = new GravitySnapHelper(Gravity.START);
        snapHelper.setColumn(2);
        snapHelper.setCanPageScroll(true);
        snapHelper.setItemOffset(30);
        snapHelper.attachToRecyclerView(mRecyclerView);


//        new GridPagerSnapHelper(1,2).attachToRecyclerView(mRecyclerView);

    }

    private void initData() {
        mData = new ArrayList<>();
        for (int i= 0;i<9;i++){
            mData.add("i="+i);
        }
    }

}
